<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <link rel="stylesheet" href="https://cdn.bootcss.com/bootstrap/3.3.7/css/bootstrap.min.css" integrity="sha384-BVYiiSIFeK1dGmJRAkycuHAHRg32OmUcww7on3RYdg4Va+PmSTsz/K68vbdEjh4u" crossorigin="anonymous">
    <style>
        form{
        width: 800px;position: absolute;left:0;
        top: 0;
        right: 0; bottom: 0;
        margin: auto;
    }
    </style>
    <script src="/static/js/jQuerynew.js"></script>
    <script src="/static/js/jquery.validate.min.js"></script>

</head>
<body style="background-color: #ffffff">
    <form action="/addtea/" method="post">
        <input type="text" name="name" id="name" class="form-control" placeholder="教师姓名" style="background-color: #ffffff"><br>
        <input type="text" name="tnumber" id="tnumber" value="uek-yg-" class="form-control" placeholder="教师工号" style="background-color: #ffffff"><br>
        <br>
        所带课程：
        {% for item in classInfo %}

            <input type="checkbox" name="pid" value="{{ item.id }}">{{ item.pname }}
        {% endfor %}
        <input type="submit">
        <input type="reset">
    </form>
    <script>
        $().ready(function () {
            $("form").validate({
                rules:{
                    name:{
                        required:true,
                        minlength:2
                    },
                    tnumber:{
                        required:true,
                        minlength:10,
                        remote: "/ajax/"
                    }
                },
                messages:{
                    name:{
                        required:"姓名必须存在",
                        minlength:"不少于2位"
                    },
                    tnumber:{
                        required:"工号必须存在",
                        minlength:"不少于10位",
                        remote: "工号已存在"
                    }
                }
            })
        })
    </script>
</body>
</html>